//
//  MineYLViewController.m
//  EasyToTesco
//
//  Created by mc on 16/3/2.
//  Copyright © 2016年 Jack. All rights reserved.
//

#import "MineYLViewController.h"
#import "HeaderFileForEasyToTesco.h"

//绑定手机号
#import "BindPhoneNumViewController.h"
//绑定加油卡
#import "BindOilcardViewController.h"
//修改登录密码
#import "ChangepwdViewController.h"
//修改支付密码
#import "ChangePayPwdViewController.h"



@interface MineYLViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong)UITableView *MineYLtableview;

@end

@implementation MineYLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self addMineYLTopview];
    [self addMineyltableview];
    
}
- (void)addMineYLTopview {
    
    UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, (self.secondView.frame.size.height-20)/2, 20, 20)];
    image1.image = [UIImage imageNamed:@"goback-icon.png"];
    [self.secondView addSubview:image1];
    self.leftBtn.hidden = YES;
    
    UIButton *goBackBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    goBackBtn.frame = CGRectMake(0, 0, self.secondView.frame.size.height, self.secondView.frame.size.height);
    [goBackBtn addTarget:self action:@selector(gobackClick) forControlEvents:UIControlEventTouchUpInside];
    [self.secondView addSubview:goBackBtn];
    self.titleLabel.text = @"我的亿乐账户";

}

//返回上一级页面
- (void)gobackClick {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)addMineyltableview{
    self.MineYLtableview = [[UITableView alloc] initWithFrame:CGRectMake(0, HIGHT*0.1, WEITH, HIGHT*0.9) style:UITableViewStylePlain];
    self.MineYLtableview.delegate = self;
    self.MineYLtableview.dataSource = self;
    self.MineYLtableview.scrollEnabled = NO;
    self.MineYLtableview.rowHeight = 50;
    self.MineYLtableview.tableFooterView = [[UIView alloc] init];
    [self.view addSubview:self.MineYLtableview];
}


#pragma mark -- UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *identifier = @"MineYLCELL";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.textLabel.font = [UIFont systemFontOfSize:16];
        }
    
    if (indexPath.section == 0) {
        cell.textLabel.text = @"绑定手机号";
    } else if (indexPath.section == 1){
        cell.textLabel.text = @"登录密码修改";
    } else if (indexPath.section == 2){
        cell.textLabel.text = @"支付密码修改";
    }else {
        cell.textLabel.text = @"绑定加油卡";
    }
    
    return cell;
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}
#pragma mark -- UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 5;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headerview = [[UIView alloc] init];
    headerview.backgroundColor =[UIColor grayColor];
    headerview.alpha = 0.4;
    return headerview;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        BindPhoneNumViewController *phonenumVC = [[BindPhoneNumViewController alloc] init];
        [self presentViewController:phonenumVC animated:YES completion:nil];
    } else if (indexPath.section == 1){
        ChangepwdViewController *changepwd = [[ChangepwdViewController alloc] init];
        [self presentViewController:changepwd animated:YES completion:nil];
    } else if (indexPath.section == 2){
        ChangePayPwdViewController *payPwdVC = [[ChangePayPwdViewController alloc] init];
        [self presentViewController:payPwdVC animated:YES completion:nil];
    } else {
        BindOilcardViewController *oilcard = [[BindOilcardViewController alloc] init];
        [self presentViewController:oilcard animated:YES completion:nil];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
